<?
    class PrincipioLab_LinkedList_ListElementIterator implements Iterator
    {
        private $linked_list;
        private $list_element;

        public function __construct(PrincipioLab_LinkedList $linked_list)
        {
            $this->linked_list = $linked_list;
            $this->list_element = $linked_list->getRootItem();
        }


        public function rewind()
        {
            $this->list_element = $this->linked_list->getRootItem();
        }


        public function current()
        {
            return $this->list_element;
        }


        public function key()
        {
            return $this->list_element->getID();
        }


        public function next()
        {
            $this->list_element = $this->list_element->getNext();
        }


        public function valid()
        {
            return (!is_null($this->list_element));
        }
    }
?>